package com.common.www.bean.vo;

import org.springframework.boot.base.jpa.domain.entity.BaseEntity;
import com.common.www.bean.entity.auth.BaseUserInf;
import com.common.www.utils.TxtUtil;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * 用户Vo
 *
 * @param
 * @author andyliu
 * @date 5/28/2018 4:23 PM
 * @return
 */
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "UserVO", description = "用户Vo")
public class UserVo extends BaseEntity implements BaseUserInf {
    private static final long serialVersionUID = -1233730442610678092L;
    @ApiModelProperty("名字")
    private String name;

    @ApiModelProperty("用户名")
    private String username;

    @ApiModelProperty("用户名")
    private String nickName;


    private String companyName;
    private Long companyId;
    private String companyIds;

    /**
     * 身份号
     */
    private String cardNum;
    /**
     * 年龄
     */
    private Integer age;
    /**
     * desc
     */
    private String des;
    /**
     * 邮箱
     */
    private String email;
    /**
     * 所属医院
     */
    private String hospital;
    /**
     * 所属科室
     */
    private String hospitalSubject;
    /**
     * 省市区
     */
    private String province;
    /**
     * 省市区
     */
    private String city;
    /**
     * 省市区
     */
    private String region;

//    @JsonIgnoreProperties(value = {"parent", "children"})
//    @ManyToOne()
//    @JoinColumn(name = "provinceCity")
//    private ProvinceCity provinceCity;

    /**
     * 城市编码
     */
    @Column(length = 20)
    private Long code;

    /**
     * 开放平台的id(用户名、手机号、第三方平台都可以作为登录的凭证)
     */
    private String openId;
    /**
     * 状态 -1.未通过审核 1.审核中 10.认证通过
     */
    @Column(length = 1)
    private Integer status;
    /**
     * 未通过备注
     */
    private String remark;
    /**
     * 七牛图片相对地址
     */
    private String avatar;
    /**
     * 动态下载地址
     */
    public String avatarUrl;
    /**
     * 性别 1.男 2.女
     */
    public Integer gender;

    @ApiModelProperty("电话号码")
    private String phone;
    /**
     * 用户是否被锁定
     */
    private Boolean locked = false;
    private Integer privacyPhone;
    @ApiModelProperty("角色")
    private List<RoleVO> roleVOS = new ArrayList<RoleVO>(0);

    @ApiModelProperty(value = "用户的所有操作权限")
    private List<String> accessList = new ArrayList<>();

    @ApiModelProperty("token")
    private String token;
    @ApiModelProperty("jPushId")
    private String jPushId;
    @ApiModelProperty("jPushId")
    private String notNullName;

    public String getNotNullName() {
        if (!TxtUtil.isEmpty(nickName)) {
            return nickName;
        } else if (!TxtUtil.isEmpty(name)) {
            return name;
        } else if (!TxtUtil.isEmpty(username)) {
            return username;
        }
        return id;
    }

    /**
     * 是否更新用户信息
     */
    Boolean updateUserInfo;
    /**
     * 用户存在标志
     * 可以逻辑删除
     */
    private Integer flag;


    /**
     * 七牛图片相对地址
     */
    private String idCardPathFront;
    /**
     * 七牛图片相对地址
     */
    private String idCardPathReverse;

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }
}
